local SceneManager = {}
SceneManager.name = ""
SceneManager.LoadingPanel = nil
SceneManager.finishCb = nil
SceneManager.loading = false
SceneManager.oldName = ""
SceneManager.scene = nil

function SceneManager:init()
	-- MessageMgr:RegisterLuaMessage(GameDefine.BuildInfoChange, self.BuildChangeInfo())
end

function SceneManager:LoadScene(sceneName, loading, cb)
	self.name = sceneName
	if self.scene ~= nil then
		self.scene:UnLoadScene()
	end
	
	self.finishCb = cb
	self.loading = loading
	if loading then
		self.LoadingPanel = UIMgr:Open("LoadingPanel", cb)
	end
	-- if self.oldName ~= ""  then
	-- 	CSDefine.ResManager:UnLoadAssetBundle(CSDefine.ResType.Scene, self.oldName)
	-- end
	CS.LoadSceneManager.Instance:LoadScene(sceneName, function()
		self.scene = require("Scene/"..sceneName.."Scene")
		self.scene:LoadScene()
		self.oldName = sceneName
	end)
end

function SceneManager.BuildChangeInfo()
	--场景物件消息变化以后进行刷新物件的状态
end


function SceneManager:UpdateProcess(args)
	Debug.Log("args[0] ==== {0}",args[0])
	if self.loading then
		self.LoadingPanel:UpdateProcess(args[0])
	end
end

function SceneManager:CurScene()
    return self.name
end

function SceneManager:SceneFinish()
	--没有loading的情况下进行回调
	if self.loading then
		self.LoadingPanel:SceneFinish()
	end
	if self.finishCb then
		self.finishCb()
	end
end

return SceneManager